import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../pages/Home'
import About from '../pages/About'
import PageNotFound from '../pages/PageNotFound'
import News from '../pages/News'
import Message from '../pages/Message'
import Detail from '../pages/Detail'
Vue.use(VueRouter)

const router = new VueRouter({
    // 配置路由模式： 默认是hash模式
    mode:'history', //  使用h5模式
    // 配置路由表
    routes: [
        {
            name:'zhuye',
            path: '/home',
            component: Home,
            // 子路由配置
            children:[
                {
                    name:'xinwen',
                    path:'/home/news',
                    component:News
                },
                {
                    // 子路由路径可以简写，注意前面没有 /
                    name:'xiaoxi',
                    path:'message',
                    component:Message,
                    children:[
                        {
                            path:'detail',
                            component:Detail
                        }
                    ]
                },
                {
                    path:'/home',
                    redirect:'/home/news'
                }
            ]
        },
        {
            name:'guanyu',
            path: '/about',
            component: About
        },
        {
            path: '/',
            // 路由重定向 配置默认页
            redirect: '/home'
        },
        {
            // 配置404页面
            path: '*',
            component: PageNotFound
        }
    ]
})

export default router